/*************************************************************************
	> File Name: P2681.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-10 10:06:57
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 1000

int arr[MAX_N + 5];

int search(int m, int n) {
    int cnt = 0, ans = 0;;
    map<int, int> mp;
    for (int i = m; i <= n; i++) {
        mp[arr[i]] += 1;
        if (mp[arr[i]] > cnt) {
            cnt = mp[arr[i]];
            ans = arr[i];
        } else if (mp[arr[i]] == cnt) {
            if (arr[i] < ans) {
                cnt = mp[arr[i]];
                ans = arr[i];
            }
        }
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    while (m--) {
        int flag, x, y;
        cin >> flag >> x >> y;
        switch (flag) {
            case 0:
                cout << search(x, y) << endl;
                break;
            case 1:
                arr[x] = y;
                break;
        }
    }
    return 0;
}
